package com.iwjw.ibatis.plugins.dynamic.spring;

import lombok.NoArgsConstructor;

/**
 * 保存当前线程读写库选择清空
 *
 * @author: huangweiwei
 * @email: ihuangweiwei@163.com
 * @created:2016/10/25
 */
@NoArgsConstructor
public class DynamicDataSourceHolder {
    private static final ThreadLocal<DynamicDataSourceGlobal> holder = new ThreadLocal<DynamicDataSourceGlobal>();

    public static void putDataSource(DynamicDataSourceGlobal dataSource) {
        holder.set(dataSource);
    }

    public static DynamicDataSourceGlobal getDataSource() {
        return holder.get();
    }

    public static void clearDataSource() {
        holder.remove();
    }

}
